/*
* This file is a part of the open-eBackup project.
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
* If a copy of the MPL was not distributed with this file, You can obtain one at
* http://mozilla.org/MPL/2.0/.
*
* Copyright (c) [2024] Huawei Technologies Co.,Ltd.
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
*/
#include "gtest/gtest.h"
#include <iostream>
#include "common/ErrorCode.h"

/********
测试用例描述:
    预置条件:  xxxx
    操作步骤:  测试预置的错误嘛是否正确
    预期结果:  xxxx
********/
TEST(TestErrorCode, TestAllErrorCode)
{
    EXPECT_EQ(ERROR_COMMON_SCRIPT_EXEC_FAILED              ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_COMMON_EXEC_FAILED));
    EXPECT_EQ(ERROR_COMMON_SCRIPT_SIGN_CHECK_FAILED        ,ErrorCode::GetInstance().GetErrorCode(ERROR_COMMON_SCRIPT_SIGN_CHECK_FAILED));
    EXPECT_EQ(ERROR_COMMON_OPER_FAILED                     ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_COMMON_RESULT_FILE_NOT_EXIST));
    EXPECT_EQ(ERROR_COMMON_OPER_FAILED                     ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_COMMON_TMP_FILE_IS_NOT_EXIST));
    EXPECT_EQ(ERROR_COMMON_OPER_FAILED                     ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_COMMON_PATH_WRONG));
    EXPECT_EQ(ERROR_COMMON_INVALID_PARAM                   ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_COMMON_PARAM_WRONG));
    EXPECT_EQ(ERROR_COMMON_DB_USERPWD_WRONG                ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_COMMON_DB_USERPWD_WRONG));
    EXPECT_EQ(ERROR_COMMON_RECOVER_INSTANCE_NOSTART        ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_COMMON_INSTANCE_NOSTART));
    EXPECT_EQ(ERROR_COMMON_DB_INSUFFICIENT_PERMISSION      ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_COMMON_INSUFFICIENT_WRONG));
    EXPECT_EQ(ERROR_COMMON_NOSUPPORT_DBFILE_ON_BLOCKDEVICE ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_COMMON_NOSUPPORT_DBFILE_ON_BLOCKDEVICE));
    EXPECT_EQ(ERROR_COMMON_DB_FILE_NOT_EXIST               ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_DB_FILE_NOT_EXIST));
    EXPECT_EQ(ERROR_DEVICE_FILESYS_MOUNT_FAILED            ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_COMMON_DEVICE_FILESYS_MOUNT_FAILED));
    EXPECT_EQ(ERROR_DEVICE_FILESYS_UNMOUNT_FAILED          ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_COMMON_DEVICE_FILESYS_UNMOUNT_FAILED));
    EXPECT_EQ(ERROR_ORACLE_ASM_DBUSERPWD_WRONG             ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_ASM_DBUSERPWD_WRONG));
    EXPECT_EQ(ERROR_ORACLE_ASM_INSUFFICIENT_WRONG          ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_ASM_INSUFFICIENT_WRONG));
    EXPECT_EQ(ERROR_ORACLE_ASM_RECOVER_INSTANCE_NOSTART    ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_ASM_INSTANCE_NOSTART));
    EXPECT_EQ(ERROR_ORACLE_NOARCHIVE_MODE                  ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_NOARCHIVE_MODE));
    EXPECT_EQ(ERROR_ORACLE_OVER_ARCHIVE_USING              ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_OVER_ARCHIVE_USING));
    EXPECT_EQ(ERROR_ORACLE_ASM_DISKGROUP_ALREADYMOUNT      ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_ASM_DISKGROUP_ALREADYMOUNT));
    EXPECT_EQ(ERROR_ORACLE_ASM_DISKGROUP_NOTMOUNT          ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_ASM_DISKGROUP_NOTMOUNT));
    EXPECT_EQ(ERROR_ORACLE_OVER_MAX_LINK                   ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_APPLICATION_OVER_MAX_LINK));
    EXPECT_EQ(ERROR_ORACLE_IN_BACKUP                       ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_DB_ALREADY_INBACKUP));
    EXPECT_EQ(ERROR_ORACLE_NOT_IN_BACKUP                   ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_DB_INHOT_BACKUP));
    EXPECT_EQ(ERROR_ORACLE_DB_ALREADYRUNNING               ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_DB_ALREADYRUNNING));
    EXPECT_EQ(ERROR_ORACLE_DB_ALREADYMOUNT                 ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_DB_ALREADYMOUNT));
    EXPECT_EQ(ERROR_ORACLE_DB_ALREADYOPEN                  ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_DB_ALREADYOPEN));
    EXPECT_EQ(ERROR_ORACLE_ARCHIVE_FAILED                  ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_DB_ARCHIVEERROR));
    EXPECT_EQ(ERROR_ORACLE_BEGIN_HOT_BACKUP_FAILED         ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_BEGIN_HOT_BACKUP_FAILED));
    EXPECT_EQ(ERROR_ORACLE_END_HOT_BACKUP_FAILED           ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_END_HOT_BACKUP_FAILED));
    EXPECT_EQ(ERROR_ORACLE_BEGIN_HOT_BACKUP_TIMEOUT        ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_BEGIN_HOT_BACKUP_TIMEOUT));
    EXPECT_EQ(ERROR_ORACLE_TRUNCATE_LOG_FAILED             ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_TRUNCATE_ARCHIVELOG_FAILED));
    EXPECT_EQ(ERROR_ORACLE_TNS_PROTOCOL_ADAPTER            ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_TNS_PROTOCOL_ADAPTER));
    EXPECT_EQ(ERROR_SCRIPT_ORACLE_NOT_INSTALLED            ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_NOT_INSTALLED));
    EXPECT_EQ(ERROR_ORACLE_INSTANCE_NOT_CDB                ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_INST_NOT_CDB));
    EXPECT_EQ(ERROR_SQLSERVER_DB_NOT_EXIST                 ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_PDB_NOT_EXIT));
    EXPECT_EQ(ERROR_SQLSERVER_START_DB_FAILED              ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_ORACLE_START_PDB_FAILED));
    EXPECT_EQ(ERROR_DB2_SUSPEND_IO_FAILED                  ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_DB2_SUSPEND_IO_FAILED));
    EXPECT_EQ(ERROR_DB2_RESUME_IO_FAILED                   ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_DB2_RESUME_IO_FAILED));
    EXPECT_EQ(ERROR_DB2_SUSPEND_IO_TIMEOUT                 ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_DB2_SUSPEND_IO_TIMEOUT));
    EXPECT_EQ(ERROR_EXCHANGE_REMOVE_FAILED                 ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_EXCHANGE_REMOVE_FAILED));
    EXPECT_EQ(ERROR_EXCHANGE_SOFTRECVERY_FAILED            ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_EXCHANGE_SOFTRECVERY_FAILED));
    EXPECT_EQ(ERROR_EXCHANGE_MOUNT_FAILED                  ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_EXCHANGE_MOUNT_FAILED));
    EXPECT_EQ(ERROR_EXCHANE_MOUNT_INMULTIAD_FAIL           ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_EXCHANGE_MOUNT_INMULTIAD_FAIL));
    EXPECT_EQ(ERROR_COMMON_SCRIPT_FILE_NOT_EXIST           ,ErrorCode::GetInstance().GetErrorCode(INTER_ERROR_SRCIPT_FILE_NOT_EXIST));
    EXPECT_EQ(ERROR_COMMON_OPER_FAILED                     ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_SQLSERVER_DEFAULT_ERROR));
    EXPECT_EQ(ERROR_CLUSTER_QUERY_FAILED                   ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_SQLSERVER_GET_CLUSTER_INFO_FAILED));
    EXPECT_EQ(ERROR_CLUSTER_PACKAGE_ONLINE_FAILED          ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_CLUSTER_RESOURCE_ONLINE_FAILED));
    EXPECT_EQ(ERROR_CLUSTER_PACKAGE_OFFLINE_FAILED         ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_CLUSTER_RESOURCE_OFFLINE_FAILED));
    EXPECT_EQ(ERROR_CLUSTER_SERVICE_NOSTART                ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_CLUSTER_SERVICE_NOSTART));
    EXPECT_EQ(ERROR_CLUSTER_DB_NOT_INCLUSTER               ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_CLUSTER_DB_NOT_INCLUSTER));
    EXPECT_EQ(ERROR_CLUSTER_RESOURCE_STATUS_ABNORMAL       ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_CLUSTER_RESOURCE_STATUS_ABNORMAL));
    EXPECT_EQ(ERROR_SQLSERVER_GET_DB_STATUS_FAILED         ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_SQLSERVER_QUERY_DB_STATUS_FAILED));
    EXPECT_EQ(ERROR_SQLSERVER_DB_STATUS_OFFLINE            ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_SQLSERVER_DB_STATUS_OFFLINE));
    EXPECT_EQ(ERROR_SQLSERVER_INSTANCE_NOT_EXIST           ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_SQLSERVER_INSTANCE_NOT_EXIST));
    EXPECT_EQ(ERROR_SQLSERVER_DB_NOT_EXIST                 ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_SQLSERVER_DB_NOT_EXIST));
    EXPECT_EQ(ERROR_COMMON_OPER_FAILED                     ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_SQLSERVER_GET_OSQL_TOOL_FAILED));
    EXPECT_EQ(ERROR_SQLSERVER_START_INSTANCE_FAILED        ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_SQLSERVER_START_INSTANCE_FAILED));
    EXPECT_EQ(ERROR_CLUSTER_NOT_ACTIVE_NODE                ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_CLUSTER_NOT_ACTIVE_NODE));
    EXPECT_EQ(ERROR_COMMON_OPER_FAILED                     ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_APP_FAILED));
    EXPECT_EQ(ERROR_LINUX_V2C_MOUNT_FAILED                 ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_LINUX_V2C_MOUNT_FAILED));
    EXPECT_EQ(ERROR_LINUX_V2C_CHECK_FSTAB_FAILED           ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_LINUX_V2C_CHECK_FSTAB_FAILED));
    EXPECT_EQ(ERROR_LINUX_V2C_VERSION_UNSUPPORTED          ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_LINUX_V2C_VERSION_UNSUPPORTED));
    EXPECT_EQ(ERROR_LINUX_V2C_GRUBFILE_NOT_FOUND           ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_LINUX_V2C_GRUBFILE_NOT_FOUND));
    EXPECT_EQ(ERROR_LINUX_V2C_INITRD_NOT_FOUND             ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_LINUX_V2C_INITRD_NOT_FOUND));
    EXPECT_EQ(ERROR_LINUX_V2C_MODIFY_GRUB_FAILED           ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_LINUX_V2C_MODIFY_GRUB_FAILED));
    EXPECT_EQ(ERROR_LINUX_V2C_DELETE_OLD_DRIVER_FAILED     ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_LINUX_V2C_DELETE_OLD_DRIVER_FAILED));
    EXPECT_EQ(ERROR_LINUX_V2C_DELETE_VMWARE_TOOL_FAILED    ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_LINUX_V2C_DELETE_VMWARE_TOOL_FAILED));
    EXPECT_EQ(ERROR_LINUX_V2C_ADD_KERNEL_PARAM_FAILED      ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_LINUX_V2C_ADD_KERNEL_PARAM_FAILED));
    EXPECT_EQ(ERROR_LINUX_V2C_MODIFY_MKINITRD_CONF_FAILED  ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_LINUX_V2C_MODIFY_MKINITRD_CONF_FAILED));
    EXPECT_EQ(ERROR_LINUX_V2C_REMAKE_INITRD_FAILED         ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_LINUX_V2C_REMAKE_INITRD_FAILED));
    EXPECT_EQ(ERROR_WINDOWS_V2C_RESCAN_DISK_FAILED         ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_WINDOWS_V2C_RESCAN_DISK_FAILED));
    EXPECT_EQ(ERROR_WINDOWS_V2C_DISK_LETTER_NOT_IN_RANGE   ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_WINDOWS_V2C_DISK_LETTER_NOT_IN_RANGE));
    EXPECT_EQ(ERROR_WINDOWS_V2C_REGLOAD_FAILED             ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_WINDOWS_V2C_REGLOAD_FAILED));
    EXPECT_EQ(ERROR_WINDOWS_V2C_VERSION_UNSUPPORTED        ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_WINDOWS_V2C_VERSION_UNSUPPORTED));
    EXPECT_EQ(ERROR_WINDOWS_V2C_INSTALL_DRIVER_FAILED      ,ErrorCode::GetInstance().GetErrorCode(ERROR_SCRIPT_WINDOWS_V2C_INSTALL_DRIVER_FAILED));
}


